//
//  walletDetailViewController.m
//  ChinaA
//
//  Created by Mxionlly on 2018/11/5.
//  Copyright © 2018 Evan. All rights reserved.
//

#import "walletDetailViewController.h"
#import "AssetsListTableViewCell.h"
#import "taskOverviewService.h"

@interface walletDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)    UITableView *tableView;
@property (nonatomic,strong)    NSArray     *cellArray;
@property (nonatomic,strong)dataUserBurseInfo *model;
@property (nonatomic,strong)UILabel *lbchina;
@end

@implementation walletDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title =@"记录详情";
    [self initUI];
}

-(void)initUI{
    self.cellArray = @[@"发款方",@"收款方",@"矿工费用",@"备注",@"交易号",@"交易时间"];
    self.lbchina = [[UILabel alloc]initWithFrame:CGRectMake(0, 140, KScreenWidth, 20)];
    self.lbchina.textAlignment = NSTextAlignmentCenter;
    self.lbchina.font = [UIFont systemFontOfSize:14];
    self.lbchina.textColor = COLOR_main;
    [self.view addSubview:self.lbchina];
    [self.view addSubview:self.tableView];
}

-(void)setBurseid:(NSString *)burseid
{
    _burseid = burseid;
    [self loadData];
}

-(void)loadData{
    NSMutableDictionary *dict = [NSMutableDictionary new];
    [dict setField:self.burseid value:@"burseid"];
    [taskOverviewService getUserBurseInfoById:dict success:^(dataSourcedataUserModel *response, BOOL success) {
        if (success) {
            self.model = response.data;
            self.lbchina.text = [NSString stringWithFormat:@"%@ china-A",self.model.RealChinaANumber];
            [self.tableView reloadData];
        }else{
            [DKProgressHUD showErrorWithStatus:response.message];
        }
    } failture:^(NSError *error, NSString *strDescription) {
        [DKProgressHUD dismiss];
        [DKProgressHUD showErrorWithStatus:strDescription];
    }];
}

#pragma mark - loadtableview

-(UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, distanceHeight, KScreenWidth, KScreenHeight-distanceHeight) style:UITableViewStylePlain];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor  = [UIColor clearColor];
        _tableView.userInteractionEnabled = YES;
    }
    return _tableView;
}

#pragma mark - UITableView
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.cellArray count];
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.0001;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.00001;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 3) {
        return 150;
    }
    return 70;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AssetsListTableViewCell *cell = [AssetsListTableViewCell cellWithTableView1:tableView];
    cell.lbtitle.text = self.cellArray[indexPath.row];
    switch (indexPath.row) {
        case 0:
        {
            cell.lbcontent.text  = self.model.RemittanceUser;
        }
            break;
        case 1:
        {
            cell.lbcontent.text = self.model.GatheringUser;
        }
            break;
        case 2:
        {
            cell.lbcontent.text = [NSString stringWithFormat:@"%@ china-A",self.model.ServiceCharge];
        }
            break;
        case 3:
        {
            cell.lbcontent.text = self.model.Remark;
        }
            break;
        case 4:
        {
            cell.lbcontent.text = self.model.OrderCode;
        }
            break;
         case 5:
        {
            cell.lbcontent.text = self.model.CreateTime;
        }
            break;
        default:
            break;
    }
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
